package com.kd.spring.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect
public class myAspect {
	// @Before("execution(* com.kd.spring.aop.StudentService.*(..))")
	/*@Before(value = "execution(* com.kd.spring.aop.StudentService.*(..))")
	public void before1(JoinPoint joinpoint) { //这个参数可以有也可无，获取所拦截的方法
		System.out.println("前置增强》》》》 拦截:"+joinpoint);
	}
	
	@AfterReturning(value = "execution(* com.kd.spring.aop.StudentService.*(..))",returning="rVal")
	public void afterReturn(JoinPoint joinPoint,Object rVal){ //返回值必须和上面的注解配置一样
		System.out.println("后置增强》》》返回值是："+rVal);
	}*/
	
	@Around(value = "execution(* com.kd.spring.aop.StudentService.*(..))")
	public Object roundObject(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
		System.out.println("前置增强》》》");
		Object returnObject = proceedingJoinPoint.proceed();
		System.out.println("后置增强》》》");
		return returnObject;
	}
	
}
